/*
 * NewCont.java
 *
 * Created on 2014-5
 */
package ui;

import DataBean.*;
import VcardTest.Images;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author Touching
 */
public class NewCont extends javax.swing.JFrame {

    int sign = 0;
    Info list;
    ArrayList<Info> List = new ArrayList();

    int row;
    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /**
     * Creates new form NewCont
     */
    /* public NewCont() {
     initComponents();
     }*/
    public NewCont(ArrayList<Info> List, int sign, int row) {
        try {
            this.sign = sign;
            this.List = List;
            this.row = row;
            initComponents();
            if (List.get(row).getBec().getPhotographs() != null && List.get(row).getBec().getPhotographs().equals("无") == false&&List.get(row).getBec().getPhotographs().matches(".*TYPE=GIF.*")==false) {
                Images.GenerateImage((String) List.get(row).getBec().getPhotographs());
                System.out.println(List.get(row).getBec().getPhotographs());
                jLabel27.setIcon(new ImageIcon(ImageIO.read(new File("./1.jpg"))));
            }
            if (sign == 1 || sign == 2) {
                this.list = List.get(row);
                name.setText(list.getBec().getName(0) + " " + list.getBec().getName(1));
                cellphone.setText(list.getBec().getMobile());
                mailbox.setText(list.getBec().getMailbox());
                birthday.setText(list.getBec().getBirth());
                notes.setText(list.getBec().getNote());

                workAddress.setText(list.getWork().getAddress());
                workCity.setText(list.getWork().getCity());
                workCountry.setText(list.getWork().getNational());
                workDepartment.setText(list.getWork().getDepartment());
                workFax.setText(list.getWork().getFax());
                workMainCode.setText(list.getWork().getCode());
                workPhone.setText(list.getWork().getTelephone());
                workPosition.setText(list.getWork().getPosition());
                workProvince.setText(list.getWork().getProvince());
                workCompany.setText(list.getWork().getUnit());

                homeAddress.setText(list.getFam().getFaddress());
                homeCountry.setText(list.getFam().getFnational());
                homeCity.setText(list.getFam().getFcity());
                homeMainCode.setText(list.getFam().getFcode());
                homePhone.setText(list.getFam().getFtelephone());
                homeProvince.setText(list.getFam().getFprovince());

                homepage.setText(list.getNet().getHomepage());
                spareEMail.setText(list.getNet().getMailbox());
                communication.setText(list.getNet().getCommunication());
            }
        } catch (IOException ex) {
            Logger.getLogger(NewCont.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public Info DataGetter() {
        Basic bec = new Basic();
        Family fam = new Family();
        Network net = new Network();
        Work work = new Work();

        String name1[] = name.getText().split(" ");
        if (name1.length < 2) {
            String[] n = {name1[0], ""};
            bec.setName(n);
        } else {
            bec.setName(name1);
        }
        if (cellphone.getText().isEmpty() == false) {
            bec.setMobile(cellphone.getText());
        }
        if (mailbox.getText().isEmpty() == false) {
            bec.setMailbox(mailbox.getText());
        }
        if (birthday.getText().isEmpty() == false) {
            bec.setBirth(birthday.getText());
        }
        if (group.getText().isEmpty() == false) {
            bec.setGroup(group.getText());
        }
        if (notes.getText().isEmpty() == false) {
            bec.setNote(notes.getText());
        }

        if (workCountry.getText().isEmpty() == false) {
            work.setNational(workCountry.getText());
        }
        if (workProvince.getText().isEmpty() == false) {
            work.setProvince(workProvince.getText());
        }
        if (workCity.getText().isEmpty() == false) {
            work.setCity(workCity.getText());
        }
        if (workAddress.getText().isEmpty() == false) {
            work.setAddress(workAddress.getText());
        }
        if (workCompany.getText().isEmpty() == false) {
            work.setUnit(workCompany.getText());
        }
        if (workDepartment.getText().isEmpty() == false) {
            work.setDepartment(workDepartment.getText());
        }
        if (workPosition.getText().isEmpty() == false) {
            work.setPosition(workPosition.getText());
        }
        if (workMainCode.getText().isEmpty() == false) {
            work.setCode(workMainCode.getText());
        }
        if (workPhone.getText().isEmpty() == false) {
            work.setTelephone(workPhone.getText());
        }
        if (workFax.getText().isEmpty() == false) {
            work.setFax(workFax.getText());
        }

        if (homepage.getText().isEmpty() == false) {
            net.setHomepage(homepage.getText());
        }
        if (communication.getText().isEmpty() == false) {
            net.setCommunication(communication.getText());
        }
        if (spareEMail.getText().isEmpty() == false) {
            net.setMailbox(spareEMail.getText());
        }

        if (homeCountry.getText().isEmpty() == false) {
            fam.setFnational(homeCountry.getText());
        }
        if (homeProvince.getText().isEmpty() == false) {
            fam.setFprovince(homeProvince.getText());
        }
        if (homeCity.getText().isEmpty() == false) {
            fam.setFcity(homeCity.getText());
        }
        if (homeAddress.getText().isEmpty() == false) {
            fam.setFaddress(homeAddress.getText());
        }
        if (homeMainCode.getText().isEmpty() == false) {
            fam.setFcode(homeMainCode.getText());
        }
        if (homePhone.getText().isEmpty() == false) {
            fam.setFtelephone(homePhone.getText());
        }
        //bec.setPhotographs(line[26].equals("") ? "无" : line[26]);
        String rev = null;
        Info temp = new Info(bec, fam, net, work, rev);
        System.out.println(temp);
        return temp;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane2 = new javax.swing.JTabbedPane();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        name = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        cellphone = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        mailbox = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        birthday = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        notes = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        group = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        homepage = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        communication = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        spareEMail = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        homeCountry = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        homeProvince = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        homeCity = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        homeAddress = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        homeMainCode = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        homePhone = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        workCountry = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        workProvince = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        workCity = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        workAddress = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        workMainCode = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        workCompany = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        workDepartment = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        workPosition = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        workPhone = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        workFax = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("联系人资料");
        setFocusCycleRoot(false);

        jLabel1.setFont(new java.awt.Font("微软雅黑", 0, 24)); // NOI18N
        jLabel1.setText("联系人资料");

        jButton1.setText("确定");
        jButton1.setToolTipText("");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("基本信息"));

        jLabel2.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel2.setText("姓名：");

        jLabel3.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel3.setText("手机号码：");

        jLabel4.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel4.setText("电子邮箱：");

        jLabel5.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel5.setText("生日：");

        birthday.setText("yyyy-mm-dd");

        jLabel6.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel6.setText("所属组：");

        jLabel7.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel7.setText("备注：");

        jLabel8.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel8.setText("照片：");

        //jLabel27.setIcon(new ImageIcon("D:\\git\\Contacts\\Java\\Contacts\\1.jpg"));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(notes, javax.swing.GroupLayout.PREFERRED_SIZE, 654, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cellphone, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel4))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(birthday, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel6)
                                .addGap(18, 18, 18)
                                .addComponent(group, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel8)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(mailbox, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                            .addComponent(jLabel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(36, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(cellphone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(mailbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(36, 36, 36)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(birthday, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(group, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel27, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(notes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(40, 40, 40))
        );

        jTabbedPane1.addTab("基本信息", jPanel1);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("网络信息"));

        jLabel13.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel13.setText("个人主页：");

        homepage.setText("http://");

        jLabel22.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel22.setText("即时通讯工具及号码：");

        communication.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                communicationActionPerformed(evt);
            }
        });

        jLabel24.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel24.setText("备用电子邮箱：");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(38, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel24)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                        .addComponent(spareEMail, javax.swing.GroupLayout.PREFERRED_SIZE, 531, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel22)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(homepage)
                            .addComponent(communication, javax.swing.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE))))
                .addContainerGap(39, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(92, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(homepage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(communication, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(spareEMail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(113, 113, 113))
        );

        jTabbedPane1.addTab("网络信息", jPanel3);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("家庭信息"));

        jLabel15.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel15.setText("国家：");

        jLabel21.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel21.setText("省份：");

        homeProvince.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeProvinceActionPerformed(evt);
            }
        });

        jLabel23.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel23.setText("城市：");

        homeCity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeCityActionPerformed(evt);
            }
        });

        jLabel25.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel25.setText("地址：");

        homeAddress.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeAddressActionPerformed(evt);
            }
        });

        jLabel26.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel26.setText("邮编：");

        jLabel30.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel30.setText("电话：");

        homePhone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homePhoneActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel23)
                        .addComponent(jLabel15))
                    .addComponent(jLabel25, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel26, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(homeCountry, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(homeProvince))
                    .addComponent(homeAddress)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(homeMainCode, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel30)
                        .addGap(10, 10, 10)
                        .addComponent(homePhone, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(homeCity))
                .addContainerGap(103, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(homeCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21)
                    .addComponent(homeProvince, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(homeCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23))
                .addGap(30, 30, 30)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(homeAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25))
                .addGap(29, 29, 29)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(homePhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel30)
                    .addComponent(homeMainCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel26))
                .addContainerGap(95, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("家庭信息", jPanel4);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("工作信息"));

        jLabel9.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel9.setText("国家：");

        jLabel10.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel10.setText("省份：");

        workProvince.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workProvinceActionPerformed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel11.setText("城市：");

        workCity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workCityActionPerformed(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel12.setText("地址：");

        workAddress.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workAddressActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel14.setText("邮编：");

        jLabel16.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel16.setText("单位：");

        jLabel17.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel17.setText("部门：");

        workDepartment.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workDepartmentActionPerformed(evt);
            }
        });

        jLabel18.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel18.setText("职位：");

        workPosition.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workPositionActionPerformed(evt);
            }
        });

        jLabel19.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel19.setText("电话：");

        workPhone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workPhoneActionPerformed(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("微软雅黑", 0, 14)); // NOI18N
        jLabel20.setText("传真：");

        workFax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workFaxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addGap(18, 18, 18)
                                .addComponent(workCity, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addGap(18, 18, 18)
                                .addComponent(workCountry)))
                        .addGap(48, 48, 48)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(workProvince))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(18, 18, 18)
                        .addComponent(workAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 531, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel16)
                                .addGap(18, 18, 18)
                                .addComponent(workCompany, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel14)
                                    .addComponent(jLabel18))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(workPosition)
                                    .addComponent(workMainCode))))
                        .addGap(42, 42, 42)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel17)
                            .addComponent(jLabel19, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel20, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(workDepartment)
                            .addComponent(workPhone)
                            .addComponent(workFax))))
                .addContainerGap(83, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(workCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(workProvince, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(workCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(workAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(workCompany, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(workDepartment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(workMainCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(workPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(workPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20)
                    .addComponent(workFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 60, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("工作信息", jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(311, 311, 311)
                .addComponent(jLabel1)
                .addContainerGap(370, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 769, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(62, 62, 62))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 365, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void workFaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workFaxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_workFaxActionPerformed

    private void workPhoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workPhoneActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_workPhoneActionPerformed

    private void workPositionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workPositionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_workPositionActionPerformed

    private void workDepartmentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workDepartmentActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_workDepartmentActionPerformed

    private void workAddressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workAddressActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_workAddressActionPerformed

    private void workCityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workCityActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_workCityActionPerformed

    private void communicationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_communicationActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_communicationActionPerformed

    private void homeProvinceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeProvinceActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_homeProvinceActionPerformed

    private void homeCityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeCityActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_homeCityActionPerformed

    private void homeAddressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeAddressActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_homeAddressActionPerformed

    private void homePhoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homePhoneActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_homePhoneActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        //新建联系人
        String warningStr = "请检查您的输入：";
        String phoneWrong = "电话号码或传真号码不能有非数字！";
        String emailWrong = "电子邮箱格式不正确！";
        String nameEmpty = "姓名不能为空！";
        String phoneEmpty = "电话号码不能为空！";
        int flag = 0;
        if (name.getText().isEmpty() == true) {
            //姓名不能为空
            System.out.println(name.getText());
            warningStr = warningStr + "\n" + nameEmpty;

            flag = 1;
        }
        if (cellphone.getText().isEmpty() == true) {
            //电话不能为空
            System.out.println(name.getText());
            warningStr = warningStr + "\n" + phoneEmpty;
            flag = 1;
        }
        if (!cellphone.getText().matches("无") && !workPhone.getText().matches("无") && !homePhone.getText().matches("无") && !workFax.getText().matches("无")) {
            if (cellphone.getText().matches("\\D") || workPhone.getText().matches("\\D") || homePhone.getText().matches("\\D") || workFax.getText().matches("\\D")) {
                //电话不能有非数字
                warningStr = warningStr + "\n" + phoneWrong;

                flag = 1;
            }
        }
        if (!mailbox.getText().matches("无") && !mailbox.getText().matches(".*@.*") && !spareEMail.getText().matches(".*@.*")) {
            //email格式
            warningStr = warningStr + "\n" + emailWrong;
            System.out.println("3");
            flag = 1;
        }
        System.out.println(flag);
        if (flag == 0) {
            //输入合法则新建联系人
            list = DataGetter();
            List = ReFlash(List, row);
            this.dispose();

        } else {
            //输入不合法，弹窗提示修改
            JOptionPane.showMessageDialog(null, warningStr);
        }

    }//GEN-LAST:event_jButton1MouseClicked

    private void workProvinceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workProvinceActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_workProvinceActionPerformed
    public void paint(ArrayList<Info> List, int sign, int row) {

        NewCont frame = new NewCont(List, sign, row);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        //frame.setSize(400, 300);
        frame.setVisible(true);
        Toolkit tk = Toolkit.getDefaultToolkit();
        Image image = tk.createImage("logo.png");
        frame.setIconImage(image);

    }

    public ArrayList<Info> ReFlash(ArrayList<Info> List, int row) {

        if (sign == 0) {
            List.add(list);
            for (int i = 0; i < List.size(); i++) {
            }
        } else if (sign == 1) {
            List.set(row, list);
        }
        return List;
    }
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new NewCont().setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField birthday;
    private javax.swing.JTextField cellphone;
    private javax.swing.JTextField communication;
    private javax.swing.JTextField group;
    private javax.swing.JTextField homeAddress;
    private javax.swing.JTextField homeCity;
    private javax.swing.JTextField homeCountry;
    private javax.swing.JTextField homeMainCode;
    private javax.swing.JTextField homePhone;
    private javax.swing.JTextField homeProvince;
    private javax.swing.JTextField homepage;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTextField mailbox;
    private javax.swing.JTextField name;
    private javax.swing.JTextField notes;
    private javax.swing.JTextField spareEMail;
    private javax.swing.JTextField workAddress;
    private javax.swing.JTextField workCity;
    private javax.swing.JTextField workCompany;
    private javax.swing.JTextField workCountry;
    private javax.swing.JTextField workDepartment;
    private javax.swing.JTextField workFax;
    private javax.swing.JTextField workMainCode;
    private javax.swing.JTextField workPhone;
    private javax.swing.JTextField workPosition;
    private javax.swing.JTextField workProvince;
    // End of variables declaration//GEN-END:variables

}
